#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int N = 40;
char pic[N][N];
int n, m;
bool vis[N][N] = { false };
int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };
priority_queue<int, deque<int>, greater<int>> ret;

void dfs(int x, int y, int boot)
{
    vis[x][y] = true;
    for (int i = 0; i < 4; i++)
    {
        int a = dx[i] + x;
        int b = dy[i] + y;
        if (a < n && b < m && vis[a][b] == false && pic[a][b] == '.')
        {
            dfs(a, b, boot + 1);
        }
        else if (a < n && b < m && vis[a][b] == false && pic[a][b] == 'e')
        {
            ret.push(boot);
            vis[a][b] = true;
        }
    }
    vis[x][y] = false;
}

int main()
{
    int x, y;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> pic[i][j];
            if (pic[i][j] == 'k')
            {
                x = i;
                y = j;
            }
        }
    }

    dfs(x, y, 1);
    if (ret.size()) cout << ret.size() << ' ' << ret.top() << endl;
    else cout << -1 << endl;
    return 0;
}